package me.jtx.poplar.user.service;

import javax.servlet.http.HttpServletRequest;

import me.jtx.poplar.core.data.BaseService;
import me.jtx.poplar.core.exception.database.NotFoundException;
import me.jtx.poplar.user.model.entity.User;

/**
 * Service class to have business logic operation on User entity
 *
 * @author: Tong Huazhong(jsyzthz@gmail.com)
 * @copyright: &copy; 2016, Tong Huazhong
 */
public interface UserService extends BaseService<User, Long> {

	/**
	 * Register a new user into the system
	 *
	 * @param user
	 * @param request
	 *
	 * @return
	 */
	public User registerUser(User user, HttpServletRequest request);

	/**
	 * Login a new user into the system
	 *
	 * @param user
	 * @param request
	 *
	 * @return
	 */
	public User loginUser(User user, HttpServletRequest request);

	/**
	 * Method to validate whether the given password is same as users password
	 * stored in the system
	 *
	 * @param user
	 * @param pass
	 *
	 * @return
	 */
	public boolean isValidPass(User user, String pass);

	/**
	 * Validates whether the given username already exists in the system.
	 *
	 * @param username
	 *
	 * @return
	 */
	public boolean isUsernameExists(String username);

	/**
	 * Validates whether the given email already exists in the system.
	 *
	 * @param email
	 *
	 * @return
	 */
	public boolean isEmailExists(String email);

	/**
	 * Finds a user entity by the given username
	 *
	 * @param username
	 * @return
	 */
	public User findByUsername(String username) throws NotFoundException;
}
